package com.xiangyi.teachingsystem.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiangyi.teachingsystem.entity.po.GroupRes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GroupResMapper extends BaseMapper<GroupRes> {

    @Select("select * from group_res where group_id=#{groupId}")
    List<GroupRes> list(Integer groupId);

    @Select("SELECT gr.* ,ug.group_name res_group_name,(\n" +
            "SELECT c.course_name\n" +
            "FROM task t\n" +
            "LEFT JOIN course c\n" +
            "ON t.course_id=c.id\n" +
            "WHERE t.id=ug.task_id\n" +
            ") res_course_name\n" +
            "FROM group_res gr\n" +
            "LEFT JOIN user_group ug\n" +
            "ON gr.group_id=ug.id")
    List<GroupRes> groupResList();
}
